import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
class Solution {
    public boolean isPalindrome(String s) {
        String sh = s.toLowerCase();
        int left = 0;
        int right = sh.length()-1;
        while (left < right){
            while (left < right && !isNumberOrDigit(sh.charAt(left))){
                left++;
            }
            while (left < right && !isNumberOrDigit(sh.charAt(right))){
                right--;
            }
            if(sh.charAt(left) == sh.charAt(right)){
                left++;
                right--;
            }
            else{
                return false;
            }
        }
        return true;
    }
    public  boolean isNumberOrDigit(char ch){

        if(Character.isLetterOrDigit(ch)){
            return true;
        }
        return  false;
    }

}
public class Main {


    public static void main(String[] args) {

        String s = "A man, a plan, a canal: Panama";
        Solution solution = new Solution();
        System.out.println(solution.isPalindrome(s));

    }
}